﻿@namespace MudBlazor
@typeparam T

<MudItem xs="1" Class="d-flex">
    <MudIconButton Icon="@Icons.Material.Filled.Close" OnClick="@RemoveFilter" Size="@Size.Small" Style="align-self:flex-end"></MudIconButton>
</MudItem>
<MudItem xs="4">
    <MudSelect Value="@Field" ValueChanged="@FieldChanged" FullWidth="true" Label="Column" Dense="true" Margin="@Margin.Dense">
        @if (DataGrid?._columns != null)
        {
            @foreach (var column in DataGrid?._columns)
            {
                <MudSelectItem Value="@column.Field">@column.Field</MudSelectItem>
            }
        }
    </MudSelect>
</MudItem>
<MudItem xs="3">
    @if (dataType == typeof(string))
    {
        <MudSelect @bind-Value="_operator" FullWidth="true" Label="Operator" Dense="true" Margin="@Margin.Dense">
            <MudSelectItem Value="@("contains")">contains</MudSelectItem>
            <MudSelectItem Value="@("equals")">equals</MudSelectItem>
            <MudSelectItem Value="@("starts with")">starts with</MudSelectItem>
            <MudSelectItem Value="@("ends with")">ends with</MudSelectItem>
            <MudSelectItem Value="@("is empty")">is empty</MudSelectItem>
            <MudSelectItem Value="@("is not empty")">is not empty</MudSelectItem>
        </MudSelect>
    }
    else if (isNumber)
    {
        <MudSelect @bind-Value="_operator" FullWidth="true" Label="Operator" Dense="true" Margin="@Margin.Dense">
            <MudSelectItem Value="@("=")">=</MudSelectItem>
            <MudSelectItem Value="@("!=")">!=</MudSelectItem>
            <MudSelectItem Value="@(">")">></MudSelectItem>
            <MudSelectItem Value="@(">=")">>=</MudSelectItem>
            <MudSelectItem Value="@("<")">@("<")</MudSelectItem>
            <MudSelectItem Value="@("<=")">@("<=")</MudSelectItem>
            <MudSelectItem Value="@("is empty")">is empty</MudSelectItem>
            <MudSelectItem Value="@("is not empty")">is not empty</MudSelectItem>
        </MudSelect>
    }
    else if (dataType.IsEnum)
    {
        <MudSelect @bind-Value="_operator" FullWidth="true" Label="Operator" Dense="true" Margin="@Margin.Dense">
            <MudSelectItem Value="@("is")">is</MudSelectItem>
            <MudSelectItem Value="@("is not")">is not</MudSelectItem>
        </MudSelect>
    }
    else if (dataType == typeof(bool))
    {
        <MudSelect @bind-Value="_operator" FullWidth="true" Label="Operator" Dense="true" Margin="@Margin.Dense">
            <MudSelectItem Value="@("is")">is</MudSelectItem>
        </MudSelect>
    }
</MudItem>
<MudItem xs="4">
    @if (dataType == typeof(string))
    {
        <MudTextField T="string" Value="@_valueString" ValueChanged="@StringValueChanged" FullWidth="true" Label="Value" Placeholder="Filter value" Margin="@Margin.Dense"></MudTextField>
    }
    else if (isNumber)
    {
        <MudNumericField T="double" Value="@_valueNumber" ValueChanged="@NumberValueChanged" FullWidth="true" Label="Value" Placeholder="Filter value" Margin="@Margin.Dense"></MudNumericField>
    }

</MudItem>